let backPage = document.querySelector('.subNav>a:nth-of-type(2)')
let ownPage = document.querySelector('.subNav>a:nth-of-type(3)')
let productid = getQueryString('productid')
let brandtitleid = getQueryString('brandtitleid')
let main = document.querySelector('#main')
let comContainer = document.querySelector('.comment>.comContainer')

fetch('http://chst.vip:1234/api/getproduct?productid=' + productid)
    .then(body => body.json())
    .then(res => {
        console.log(res);
        ownPage.innerHTML = res.result[0].productName
        ownPage.onclick = function () {
            location.reload()
        }
        let str = ''
        str += `<div class="show">
        <div class="pic">
        ${res.result[0].productImg}
        </div>
        <div class="title">
        ${res.result[0].productName}
        </div>
        <div class="count">
        <span>当前最低 ￥6000</span><span>优选评论 8266条</span>
        </div>
        </div>
        <div class="buy">
        ${res.result[0].bjShop}
        </div>`
        main.innerHTML = str

        fetch("http://chst.vip:1234/api/getproductcom?productid=" + productid)
            .then(body => body.json())
            .then(res => {
                console.log(res);
                let str = ''
                res.result.forEach(item => {
                    str += `<div class="container">
                    <div>
                    <span>${item.comName}</span>
                    <span>${item.comTiem}</span>
                    </div>
                    <p>${item.comContent}</span>
                    <div>
                    <p>${item.comFrom}</p>
                    </div>
                    </div>`
                })
                comContainer.innerHTML = str
            })
    })

let brandName = getQueryString('title')
backPage.innerHTML = brandName + '>'
backPage.onclick = function () {
    console.log(brandName)
    location.href = './brandList.html?brandtitleid=' + brandtitleid + '&brandName=' + brandName + '&pagesize=10'
}